<form class="cadre" method="<?php echo $method ?>" action="<?php echo $action ?>" <?php if ( $isEnctype ): ?>enctype="multipart/form-data"<?php endif; ?>>

    <?php
        // Champs cachés
        $hiddenFields = array();
        $resultFields = array();
        foreach ($fields AS $key=>$field) :
            if ( $field->getType() == 'hidden' ):
                $hiddenFields[] = $field;
            else:
                $resultFields[] = $field;
            endif;
        endforeach;
        $fields = $resultFields;
    ?>


    <?php $nbFields = sizeof($fields) - 1;
    $i = 0;
    ?>
    
    <?php if ( is_array($fields)):
        foreach($fields AS $field): ?>
        <div class="field" <?php if ($i >= $nbFields): ?>style="border:0;"<?php endif; ?>>
            <?php if ($field->getType() != 'text'): ?>
            <label for="<?php echo $slug ?>-<?php echo $field->getSlug() ?>">
                <span class="name"><?php if ($field->isRequired()): ?>* <?php endif; ?><?php echo $field->getName() ?> :</span>
                <?php if ( !$field->isError() ): ?>
                <span class="helper"><?php echo $field->getHelper() ?></span>
                <?php else: ?>
                <span class="error"><?php echo $field->getError() ?></span>
                <?php endif; ?>
            </label>
            <?php endif; ?>
            <?php $field->render() ?>
        </div>
        <?php $i++; ?>
    <?php endforeach;
    endif; ?>

    <?php foreach($hiddenFields AS $field) :
        $field->render();
    endforeach; ?>

    <div class="buttons">
        <?php if(is_array($links)): foreach($links AS $name=>$link): ?>
        <a href="<?php echo $link ?>"><?php echo $name ?></a> |
        <?php endforeach; endif; ?>
        <input type="submit" class="submit" name="<?php echo $slug ?>-submit" value="<?php echo $buttons['submit'] ?>" />
    </div>
</form>
<div class="form-help">Les champs marqués d'une * sont obligatoires</div>